import os
import sys

from core.rest_client import RestClient
from common.read_data import data

BASE_PATH = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
sys.path.append(BASE_PATH)
data_file_path = os.path.join(BASE_PATH, "config", "setting.ini")
api_root_url = data.load_ini(data_file_path)["host"]["api_root_url"]


class Project(RestClient):

    def __init__(self, api_root_url, **kwargs):
        super(Project, self).__init__(api_root_url, **kwargs)

    def tree(self, access_token, **kwargs):
        '''
        获取所有的文件夹
        '''
        return self.get("/api/project/tree?access_token={}".format(access_token), **kwargs)

    def create(self,**kwargs):
        '''
        创建文件夹
        '''
        return self.post("/api/project/create", **kwargs)

    def move(self,access_token, **kwargs):
        '''
        移动文件夹
        '''
        return self.post("/api/project/move?access_token={}".format(access_token), **kwargs)

    def modify(self, access_token, **kwargs):
        '''
        编辑文件夹
        '''
        return self.get("/api/project/modify?access_token={}".format(access_token), **kwargs)

    def delete(self, **kwargs):
        '''
        删除文件夹
        '''
        return self.post("/api/project/delete", **kwargs)



project = Project(api_root_url)
